home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / ge_cool.lha / GE_COOL2.1 / src / Matrix / Base_Matrix.h < prev    next >
C/C++ Source or Header  |  1992-06-11  |  3KB  |  90 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12. // Created: MBN 09/11/89 -- Initial design and implementation
  13. // Updated: VDN 02/21/92 -- New lite version
  14. //
  15. // The parameterized CoolMatrix<Type>  class is publicly   derived from the  CoolMatrix
  16. // class and implements two dimensional arithmetic matrices of a user specified
  17. // type.   This is accompilshed by using  the parameterized  type capability of
  18. // C++.  The only constraint placed on the type  is  that it must  overload the
  19. // following operators: +, -,  *,  and /. Thus, it will  be possible to have  a
  20. // matrix of  type Complex.  The CoolMatrix<Type> class  is static in size, that is
  21. // once a  CoolMatrix<Type> of  a particular  size has been   declared, there is no
  22. // dynamic growth or resize method available.
  23. //
  24. // The CoolMatrix class is the base class  for the parameterized CoolMatrix<Type> class
  25. // and   implements all non-type   specific  functionality. The  protected data
  26. // section  contains two slots  to maintain the  row and column  specification.
  27. // There are two  constructors  for  the  CoolMatrix  class.  The  first takes  two
  28. // arguments specifying the  number of rows  and columns. The   second takes  a
  29. // reference to a CoolMatrix object and reproduces its state. There  are two public
  30. // methods that provide accessors to the  row and column slots.  Finally, there
  31. // are several protected methods that are called by  the parameterized class to
  32. // handle exceptions.
  33.  
  34. #ifndef BASE_MATRIXH                // If no CoolMatrix class,
  35. #define BASE_MATRIXH                // define it
  36.  
  37. #ifndef STREAMH            // If the Stream support not yet defined,
  38. #if defined(DOS) || defined(M_XENIX)
  39. #include <stream.hxx>           // include the Stream class header file
  40. #else
  41. #include <stream.h>        // include the Stream class header file
  42. #endif
  43. #define STREAMH
  44. #endif
  45.  
  46. #ifndef MISCELANEOUSH        // If we have not included this file,
  47. #include <misc.h>        // include miscelaneous useful definitions.
  48. #endif
  49.  
  50. class CoolMatrix {
  51. public:
  52.   inline int rows () const;            // Return number of rows
  53.   inline int columns () const;            // Return number of columns
  54.  
  55. protected:
  56.   int num_rows;                    // Number of rows
  57.   int num_cols;                    // Number of columns
  58.   
  59.   void row_index_error (const char* fcn, const char* type, int) const; // Raise
  60.   void col_index_error (const char* fcn, const char* type, int) const; // exception
  61.   void dimension_error (const char* fcn, const char* type, int,int,int,int) const;
  62.   void va_arg_error (const char*, int);        // Raise exception
  63.  
  64.   CoolMatrix (int r=1, int c=1);        // CoolMatrix m (r,c);
  65.   CoolMatrix (const CoolMatrix&);        // m1 = m2;
  66.   ~CoolMatrix();                // Destructor
  67. };
  68.  
  69.  
  70. // rows -- Return the number of rows in the matrix
  71. // Input:  None
  72. // Output: Number of rows
  73.  
  74. inline int CoolMatrix::rows () const {
  75.   return this->num_rows;            // Return number of rows
  76. }
  77.  
  78.  
  79. // columns -- Return the number of columns in the matrix
  80. // Intput:    None
  81. // Output:    Number of columns
  82.  
  83. inline int CoolMatrix::columns () const {
  84.   return this->num_cols;            // Return number of columns
  85. }
  86.  
  87. #endif                        // End of BASE_MATRIXH
  88.  
  89.  
  90.